(function() {

this.codium = this.codium || {};
this.codium.panel = this.codium.panel || {};

this.codium.panel.NewPeople = pasta.webgui.Panel.extend(
{
	init : function() 
	{
		this._super();
		
		this.canvas.style.background = "rgba(0, 0, 0, 0.4)";
		this.canvas.style.zIndex = "1000";
		
		this.pnl = new pasta.webgui.ContainerControl();
		this.pnl.setWidth(400);
		this.pnl.setHeight(300);
		this.pnl.setLeft((this.getWidth() - this.pnl.getWidth()) / 2);
		this.pnl.setTop((this.getHeight() - this.pnl.getHeight()) / 3);
		this.pnl.canvas.style.background = "rgba(255, 255, 255, 0.9)";
		this.pnl.canvas.style.border = "1px solid rgba(255, 255, 255, 1)";
		this.pnl.canvas.style.webkitBoxShadow = "0px 1px 8px #000000";
		this.pnl.canvas.style.mozBoxShadow = "0px 1px 8px #000000";
		this.pnl.canvas.style.boxShadow = "0px 1px 8px #000000";
		this.pnl.canvas.style.mozBorderRadius = "6px";
		this.pnl.canvas.style.webkitBorderRadius = "6px";
		this.pnl.canvas.style.borderRadius = "6px";
		this.addControl(this.pnl);
		
			this.lblTitle = new pasta.webgui.Label();
			this.lblTitle.setCaption(".: New People");
			this.lblTitle.setWidth(this.pnl.getWidth());
			this.lblTitle.setTop(10);
			this.lblTitle.setLeft(10);
			this.lblTitle.font.setSize(16);
			this.lblTitle.font.setBold(true);
			this.pnl.addControl(this.lblTitle);
			
			this.btnCancel = new pasta.webgui.Button();
			this.btnCancel.setCaption("Cancel");
			this.btnCancel.setWidth(80);
			this.btnCancel.setTop(this.pnl.getHeight() - 40);
			this.btnCancel.setLeft(this.pnl.getWidth() - 85);
			this.btnCancel.getOnClick().setHandler(this, this.btnCancelClick);
			this.pnl.addControl(this.btnCancel);
			
			this.btnOK = new pasta.webgui.Button();
			this.btnOK.setCaption("OK");
			this.btnOK.setWidth(80);
			this.btnOK.setTop(this.btnCancel.getTop());
			this.btnOK.setLeft(this.btnCancel.getLeft() - 85);
			this.btnOK.getOnClick().setHandler(this, this.btnOKClick);
			this.pnl.addControl(this.btnOK);
			
			this.lblUserId = new pasta.webgui.Label();
			this.lblUserId.setLeft(10);
			this.lblUserId.setTop(50);
			this.lblUserId.setWidth(200);
			this.lblUserId.setCaption("User Id :");
			this.lblUserId.font.setBold(true);
			this.pnl.addControl(this.lblUserId);
			
			this.edtUserId = new pasta.webgui.Edit();
			this.edtUserId.setLeft(this.lblUserId.getLeft());
			this.edtUserId.setTop(this.lblUserId.getTop() + 20);
			this.edtUserId.setWidth(this.pnl.getWidth() - (2 * this.edtUserId.getLeft()));
			this.pnl.addControl(this.edtUserId);
			
			this.lblUserName = new pasta.webgui.Label();
			this.lblUserName.setLeft(10);
			this.lblUserName.setTop(this.edtUserId.getTop() + 30);
			this.lblUserName.setWidth(200);
			this.lblUserName.setCaption("User Name :");
			this.lblUserName.font.setBold(true);
			this.pnl.addControl(this.lblUserName);
			
			this.edtUserName = new pasta.webgui.Edit();
			this.edtUserName.setLeft(this.lblUserName.getLeft());
			this.edtUserName.setTop(this.lblUserName.getTop() + 20);
			this.edtUserName.setWidth(this.pnl.getWidth() - (2 * this.edtUserName.getLeft()));
			this.pnl.addControl(this.edtUserName);
			
			this.lblPassword = new pasta.webgui.Label();
			this.lblPassword.setLeft(10);
			this.lblPassword.setTop(this.edtUserName.getTop() + 30);
			this.lblPassword.setWidth(200);
			this.lblPassword.setCaption("Password :");
			this.lblPassword.font.setBold(true);
			this.pnl.addControl(this.lblPassword);
			
			this.edtPassword = new pasta.webgui.Edit();
			this.edtPassword.setLeft(this.lblPassword.getLeft());
			this.edtPassword.setTop(this.lblPassword.getTop() + 20);
			this.edtPassword.setWidth(185);
			this.pnl.addControl(this.edtPassword);
			
			this.lblEmail = new pasta.webgui.Label();
			this.lblEmail.setLeft(10);
			this.lblEmail.setTop(this.edtPassword.getTop() + 30);
			this.lblEmail.setWidth(200);
			this.lblEmail.setCaption("Email :");
			this.lblEmail.font.setBold(true);
			this.pnl.addControl(this.lblEmail);
			
			this.edtEmail = new pasta.webgui.Edit();
			this.edtEmail.setLeft(this.lblEmail.getLeft());
			this.edtEmail.setTop(this.lblEmail.getTop() + 20);
			this.edtEmail.setWidth(185);
			this.pnl.addControl(this.edtEmail);
			
			this.lblRole = new pasta.webgui.Label();
			this.lblRole.setLeft(205);
			this.lblRole.setTop(this.lblEmail.getTop());
			this.lblRole.setWidth(200);
			this.lblRole.setCaption("Role :");
			this.lblRole.font.setBold(true);
			this.pnl.addControl(this.lblRole);
			
			this.ddbRole = new pasta.webgui.DropDownBox();
			this.ddbRole.setLeft(this.lblRole.getLeft());
			this.ddbRole.setTop(this.lblRole.getTop() + 20);
			this.ddbRole.setWidth(180);
			this.pnl.addControl(this.ddbRole);
			
			this.ddbRole.addItem("1", "Administrator");
			this.ddbRole.addItem("2", "Staff");
		
		this.setVisible(false);
	},
	
	//--------------------- Service Event ---------------------
	
	//--------------------- Event ---------------------
	
	show : function()
	{
		this.initSize();
		
		this._super();
		this.mode = 1;
		
		this.edtUserId.setReadOnly(false);
		
		this.edtUserId.setText("");
		this.edtUserName.setText("");
		this.edtPassword.setText("");
		this.edtEmail.setText("");
		this.ddbRole.setSelectedId("1");
	},
	
	showEdit : function(obj)
	{
		this.initSize();
		
		this.mode = 2;
		
		this.edtUserId.setReadOnly(true);
		
		this.edtUserId.setText(obj.userId);
		this.edtUserName.setText(obj.userName);
		this.edtPassword.setText(obj.password);
		this.edtEmail.setText(obj.email);
		this.ddbRole.setSelectedId("" + obj.roleId);
		
		this.setVisible(true);
	},
	
	initSize : function()
	{
		this.pnl.setLeft((this.getWidth() - this.pnl.getWidth()) / 2);
		this.pnl.setTop((this.getHeight() - this.pnl.getHeight()) / 3);
	},
	
	btnCancelClick : function(sender)
	{
		this.close();
	},
	
	btnOKClick : function(sender)
	{
		if (this._onOK != null)
			this._onOK.callHandler(this, 	this.edtUserId.getText(), 
											this.edtUserName.getText(),
											this.edtPassword.getText(),
											this.edtEmail.getText(),
											this.ddbRole.getSelectedId());
		
		this.close();
	},
	
	//--------------------- Setter & Getter ---------------------
	
	setWidth : function(data)
	{
		this._super(data);
		this.initSize();
	},
	
	setHeight : function(data)
	{
		this._super(data);
		this.initSize();
	},
	
	getOnOK : function()
	{
		if (this._onOK == null)
			this._onOK = new pasta.util.EventObj();
		
		return this._onOK;
	},
});
	
})();